export const showToast = (message: string, icon: any = 'none', duration = 2000) => {
  uni
    .showToast({
      title: message,
      icon: icon,
      duration: duration
    })
    .then(() => {})
}

export const showModal = ({ title = '提示', content = '', confirmText = '确定', cancelText = '取消', success = () => {}, cancel }: any) => {
  uni.showModal({
    title: title,
    content: content,
    confirmText: confirmText,
    cancelText: cancelText,
    showCancel: cancel ? true : false,
    success: (res: any) => {
      if (res.confirm) {
        success()
      } else if (res.cancel) {
        cancel && cancel()
      }
    }
  })
}

export const showLoading = (title = '处理中...') => {
  uni.showLoading({
    title: title
  })
}

export const hideLoading = () => {
  uni.hideLoading()
}
